repl: add syntax highlighting, auto-indentation, and signature hints#64443
repl: add syntax highlighting, auto-indentation, and signature hints#64443hemanth wants to merge 1 commit into
Conversation
|
Review requested:
|
30413de to
14baff1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64443 +/- ##
==========================================
- Coverage 90.23% 90.20% -0.03%
==========================================
Files 741 741
Lines 241375 242165 +790
Branches 45483 45628 +145
==========================================
+ Hits 217800 218454 +654
- Misses 15129 15247 +118
- Partials 8446 8464 +18
🚀 New features to boost your workflow:
|
16ee02c to
b749718
Compare
avivkeller
left a comment
There was a problem hiding this comment.
can these be idiomatic PRs?
|
@avivkeller for sure! having some challenges on my local machine, so depending on the GH CI to report me the build time errors. |
1e7bcec to
088a905
Compare
|
this one has been in my list forever; I thik this should dogfood |
|
Agree. |
Add experimental REPL enhancements behind the --experimental-repl-enhancements flag: 1. Inline syntax highlighting using the Acorn tokenizer to colorize keywords (magenta), strings (green), numbers (yellow), booleans/null (yellow), regular expressions (red), and comments (gray). 2. Auto-indentation for multiline input based on brace/bracket/paren depth, using 2-space indentation. 3. Function signature hints that display parameter lists as dimmed text below the input when the user types a function call. All features are off by default and require the CLI flag to enable. Highlighting is applied at display time only so cursor positioning and evaluation are unaffected. Refs: nodejs#48164 Signed-off-by: hemanth <hemanth.hm@gmail.com>
088a905 to
eec5763
Compare
| added: REPLACEME | ||
| --> | ||
|
|
||
| > Stability: 1 - Experimental |
There was a problem hiding this comment.
I have a feeling we should just enable it by default in a semver-major as long as it respects the NO_COLOR or FORCE_TTY
Description
Add experimental REPL enhancements behind the
--experimental-repl-enhancementsCLI flag:1. Inline Syntax Highlighting
Uses the Acorn tokenizer (already in
deps/) to colorize JavaScript input in real-time:const,function,if, etc.) → MagentaHighlighting is applied at display time only —
repl.lineremains plain text, so cursor positioning and evaluation are unaffected.2. Auto-Indentation
Automatically inserts 2-space indentation on continuation lines based on brace/bracket/paren depth when entering multiline input.
3. Function Signature Hints
When the user types
functionName(, the function's parameter list is displayed as a dimmed hint below the input line. Uses the V8 Inspector protocol withthrowOnSideEffect: truefor safety.Usage
All features are off by default — nothing changes for users unless they explicitly pass the flag. Individual features can also be controlled via
repl.start()options (e.g.,syntaxHighlighting: false).Motivation
This addresses the feature requests from #48164, which was closed as not planned. However, by gating everything behind an experimental flag with no behavioral changes to the default REPL, the risk profile is minimal. These are quality-of-life improvements that bring the Node.js REPL closer to modern shell experiences (Python's IPython, Ruby's Pry, etc.).
Refs: #48164